import axios from 'axios'
import { ElMessage } from 'element-plus'
const service  = axios.create({
    baseURL: '/eduAi',
    timeout: 5000
})
 
service.interceptors.request.use(config =>{
    config.headers['Content-Type'] = 'application/json'
    return config

})
service.interceptors.response.use(response =>{
    return response.data
}),error=>{
    let message= '';
    switch(error.response.status){
        case 400:
            message = '请求参数错误'
            break;
        case 401:
            message = '未授权，请登录'
            break;
        case 403:
            message = '拒绝访问'
            break;
        case 404:
            message = '请求地址错误'
            break;
        case 500:
            message = '服务器错误'
            break;

    }
    ElMessage.error(message)

    return Promise.reject(message)  

}
export default service
